import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
//配置路径别名
import path from 'path'

//主题
import tailwindcss from '@tailwindcss/vite'

// https://vite.dev/config/
export default defineConfig({
  plugins: [react(), tailwindcss()],
  server: {
    //配置跨域代理（proxy）
    proxy: {
      // 选项写法
      '/api': {
        target: 'http://blogapi.shbwyz.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
    }
  },
  //将 @ 映射到 src 目录，简化路径引用
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  }
})
